<html>
<head>
<title></title>
<script type="text/javascript" src="Core.js" id="LSFramework" charset="utf-8" shortcut="LS" debug="true" traceContainerId="traceContainer" culture="zh-CN" requestMode="xmlHttp"></script>
<style type="text/css">
div{float:left;}
</style>
</head>

<body>
<div>123 <span>.</span></div>

<div id="dv1">
    <span>10</span>
    <span name="sp">
        <img width="32" height="32" border="0" alt=""/>
    </span>
    <span name="sp"></span>
    <div>;</div>
    <img width="320" height="32" border="0" alt=""/>
</div>

<div name="dv"></div>
<div></div>
<div name="dv"><span>20</span></div>
<span name="dv"><div><span>18</span></div></span>
<div myAttr="myA"></div>
<br>

<textarea id="traceContainer" name="" rows="30" cols="130"></textarea>

<br/>

<script type="text/javascript">
<!--

LS.trace();	//Clear the trace

document.ondblclick = function()
{
    /*LS.using("LightScript.Dom", function()
    {
        //alert("ok!");
        LS.trace(["ok!", LS.Array, LS.Bom]);
    });*/
}

LS.Core.createNamespace("N.A.C");
LS.Core.createClass("N.A.C.C1");
LS.Core.createClass("N.A.C.C2");
N.A.C.C2.prototype.m2 = function()
{
    LS.trace("m2");
}
LS.Core.createClass("N.A.C.C3", function(a){LS.trace("ctor 3 " + a)});
LS.Core.createClass("N.A.C.C4: N.A.C.C1, N.A.C.C2, N.A.C.C3", function()
{
    LS.Core.base(this, N.A.C.C1);
    LS.Core.base(this, N.A.C.C2);
    LS.Core.base(this, N.A.C.C3, [123]);
});
N.A.C.C4.prototype.m4 = function()
{
    LS.trace("m4");
}
LS.Core.createClass("N.A.C.C5: N.A.C.C4");
N.A.C.C5.prototype.m5 = function()
{
    LS.Core.base(this, N.A.C.C4, "m4", [100]);   //This method is from N.A.C.C4 directly.
    LS.Core.base(this, N.A.C.C4, "m2", [100]);   //This method is from base of N.A.C.C4.
}
LS.Core.createClass("N.A.C.C6");


var cc4 = new N.A.C.C4();
var cc5 = new N.A.C.C5();
cc5.m5();
/*//var c2 = new N.A.C.C2();
var c4 = new N.A.C.C4();
var c5 = new N.A.C.C5();
//LS.trace(LS.Core.getType(c4));
//LS.trace(LS.Core.getTypeName(c2));
LS.trace(LS.Core.getTypeName(c4));
LS.trace(LS.Core.isType(c4, N.A.C.C4)); 
LS.trace("c5: " + LS.Core.isType(c5, N.A.C.C3)); 
*/

LS.using("LightScript.Resources.Resource", function()
{
    LS.trace(LS.Resource.lightScript); //Resource is the shortcut of Resources.Resource
});

/**/
LS.using("LightScript.Dom", function()
{
	var result;
	//LS.trace(LS.Dom);
	//result = LS.Dom.selectNodes("//*[@id='dv1'] | //*[@id='dv1']");
	//result = LS.Dom.selectSingleNode("/html/body").tagName;
	//result = LS.Dom.selectNodes("//div").length;
	//result = LS.Dom.selectNodes("/html/body//div");
	//result = LS.Dom.selectNodes("/html/body/div");
	//result = LS.Dom.selectSingleNode("/html/body/div[last()]").tagName;
	//result = LS.Dom.selectSingleNode("/html/body/div[position() = 1]").innerHTML;
	//result = LS.Dom.selectNodes("//div[span>1*10 and span<=20+2*1]");
	//result = LS.Dom.selectSingleNode("//div[span>1 and span<=22]/img").width;
	result = LS.Dom.selectNodes("//div[@ myAttr]");
	LS.trace("result:");
	LS.trace(result);
});

/*
LS.using("demo@LightScript._Additions.Demo$utf-8", "LightScript.Utility", "LightScript.Function", function()
{
    LS.trace(["The demo: ", demo, LS.Utility, LS.Function]);
});
//LS.using("JSON@LightScript._Additions.JsonLib.jsonlib", function()
LS.using("JSON@_Additions.JsonLib.jsonlib", function()  //Another way, if use file: protocol, there may be problems on path, so it's better to use http: to access.
{
    var json = JSON({ name: "Nicholas", age: 29 });
    json.put("sex", "male");
    json.put("gf", new JSON({ age: 28, found: true }));
    LS.trace(json.toJSONString());

    var obj = JSON.parse("{\"name\":\"Nicholas\", \"age\" : 29 , \"found\" :true, \"obj\": null}");
    LS.trace(obj.get("name"));
});

LS.using ("YAHOO.util.Dom@http://yui.yahooapis.com/2.4.0/build/yahoo-dom-event/yahoo-dom-event.js", function()
{
    LS.trace(["YAHOO ", YAHOO.util.Dom]);
});
*/

/*LS.using("LightScript.Net.WebRequest", function()
{
    //LS.Net.WebRequest.create("demo.htm", null, onSuccess, onError, {isAsync: true, method: "get"});
    LS.Net.WebRequest.create("Server.aspx", "a=1&b=2", onSuccess, onError, {isAsync: true, method: "post"});
});

LS.using("LightScript.Net.WebRequest", function()
{
    LS.Net.WebRequest.create("Json.js", null, onSuccess, onError, {requestMode: "scriptHttp"});
});


LS.using("LightScript.Net.WebRequest", function()
{
    //LS.Net.WebRequest.create("demo.htm", null, onSuccess, onError, {method: "get", requestMode: "htmlHttp"});
    LS.Net.WebRequest.create("Server.aspx", "a=1&b=2", onSuccess, onError, {method: "post", requestMode: "htmlHttp"});
});*/

function onSuccess(response)
{
    LS.trace([Math.random(), response.text.length, response.contentLength]);
    //LS.trace(response.text);
}

function onError(statusCode)
{
    LS.trace("Error..." + statusCode);
}

LS.using("LS.Components.Timer", function()
{
    new LightScript.Components.Timer(foo, 1000, 1);
});

function foo()
{
    LS.trace(new Date());
}

/*
LS.using("LightScript.Bom", function()
{
    LightScript.Bom.writeCookie("my", "a" ,1);
    LightScript.Bom.writeCookie("my", "b" ,2);
    LS.trace(LightScript.Bom.readCookie("my", "a"));
    LS.trace("cookie:" +document.cookie)
});
*/

window.onerror = function(msg, url, num)
{
    //alert([msg, num])
    //return true;
}
//throw new LightScript.Exception(null, "ErrorABC", "This is an error.");

LS.using ("LightScript.Dom", function()
{
    //LS.Dom.createPopup({innerHTML: "<br/><p>This is a popup</p>"}, true);
});

LS.using ("LightScript.Bom", function()
{
    LS.trace(LightScript.Bom.browser.version);
    LS.trace(LightScript.Bom.browser.msie);
    LS.trace(LightScript.Bom.browser.firefox);
    LS.trace(LightScript.Bom.browser.opera);
});

/*
//WebInvoke
LS.using("LightScript.Net.WebInvoke", function()
{
    LightScript.Net.WebInvoke.create("ASP.app_script_framework_lightscript_invoke_aspx+InvokeDemo", "HelloWorld", ["King", "Queen"], true, onWebInvokeSucess, onWebInvokeError, {invokeUri: "Invoke.aspx"});
});

function onWebInvokeSucess(obj)
{
     LS.trace("WebInvoke: " + obj.get("First"));
}

function onWebInvokeError(err)
{
    LS.trace("WebInvoke: " + "Error occurs: " + err);
}
*/

//-->
</script>

<div id="dvdv1">
<script type="text/javascript">
<!--
LS.using("LightScript.UI.Controls.DemoControl", function()
{
    (new LightScript.UI.Controls.DemoControl("ctl1")).render("dvdv1");
});

LS.using ("LightScript.String", function()
{
    LS.trace(LS.String.startsWith("str123", "str"));
});

LS.using ("LightScript.DateTime", function()
{
    LS.trace(LS.DateTime.addDays(new Date(), 7));
});
//-->
</script>
</div>

</body>
</html>